import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import nodejs from '@dfeidao/atom-web/msg/nodejs';
import render from '@dfeidao/atom-web/render/render';
import p001 from './p001';



import set from '@dfeidao/atom-web/global/set';
import fire from '@dfeidao/atom-web/msg/fire';
import p002 from './p002';
import p006 from './p006';


export default async function a003(fd: IFeidaoAiBrowserComponent) {
	// todo
	const question_bank_type1 = fd.data.node.querySelector<HTMLSelectElement>('[data-id="question_bank_type"]');
	const question_bank_type = question_bank_type1.value;
	const topic_type1 = fd.data.node.querySelector<HTMLSelectElement>('[data-id="topic_type"]');
	const topic_type = topic_type1.value;
	const topic1 = fd.data.node.querySelector<HTMLInputElement>('[data-id="topic"]');
	const topic = topic1.value;
	const fenye = fd.data.node.querySelector<HTMLDivElement>('[data-feidao-presentation="p003"]');
	const fenye1 = fd.data.node.querySelector<HTMLDivElement>('[data-feidao-presentation="p006"]');
	const biaoge=fd.data.node.querySelector<HTMLDivElement>('[data-id="biaoge"]');
	const kong=fd.data.node.querySelector<HTMLDivElement>('[data-id="kong"]');
	if (!question_bank_type && !topic_type && !topic) {
		fire('zj-000001', 'a010');
		fenye.style.display = "block";
		const fu=fd.data.node.querySelector<HTMLDivElement>('[data-feidao-presentation="p006"]');
		fu.style.display='none';
		kong.style.display = "none";
		biaoge.style.display = "block";
	} else {
		const res = await nodejs<{res: Array<{}> , s: Array<{}> }>('question-bank/zj-000001/s003', {
			filter: {
				question_bank_type,
				topic_type,
				topic,
				pn:1
			}
		});

		 if (res.s.length === 0 ) {
			render(fd,'',p002,'p002','inner');
			kong.style.display = "block";
			biaoge.style.display = "none";
		 } else {
			render(fd, res.res, p001, 'p001', 'inner');
			kong.style.display = "none";
			biaoge.style.display = "block";
		 }
			if (res.s.length > 20) {
				render(fd, res.res, p001, 'p001', 'inner');
				render(fd, res.s.length, p006, 'p006', 'inner');
				fenye.style.display = "none";
				fenye1.style.display = "block";

			} else {
				render(fd, res.res, p001, 'p001', 'inner');
				fenye.style.display = "none";
				fenye1.style.display = "none";
			}
	}

	set('na001',2);





}
